<?php
	$page=$model;
?>
<div class='contentheader'>
<?
if($page->type=='navitree'){
	echo sigi::actionbox('page', $page->id, 'navitree');
	
	$params=array();
	$params[]=array('title'=>'add Subpage', 'link'=>CONTDIR.'page/form/input?parent_id='.$page->id);
	echo sigi::addbox($params);		 

}else{
	//echo sigi::actionbox('page', $page->id);
	echo sigi::actionbox_small('page', $page->id);
}


// breadcrumb navigation
foreach($page->get_ancestors() as $ancestor){
	echo html::anchor(CONTDIR.'page/single/'.$ancestor->id, $ancestor->title).' / ';
}
echo $page->title;

?>
</div>
<?


if($page->type!='navitree'){
	
	// METACONTENT
	
	echo '<div class="pagemetacont">';
	//echo '<div class="toggle_head">Show Metainfo</div>';
	//echo '<div class="toggle_body">';
	$pageconts=$page->where('lang', $this->session->get('lang'))->pagecont->as_array();
	if(count($pageconts)==0){
		$params=array();
		$params[]=array('title'=>'add Page Metainfo', 'link'=>CONTDIR.'pagecont/form/input?parent_id='.$page->id);
		echo sigi::addbox($params);
		echo '<p>No Metainfo</p>';
	}
	
	foreach($pageconts as $pcont){
		echo sigi::actionbox_small('pagecont', $pcont->id);
		echo '<p>Menutitle : '.$pcont->menutitle.'</p>';
		echo '<p>Windowtitle : '.$pcont->windowtitle.'</p>';
		echo '<p>Description : '.$pcont->description.'</p>';
		echo '<p>Keywords : '.$pcont->keywords.'</p>';
	}
	//echo '</div>';
	
	echo '</div>';
}

?>


<div class='content'>
<?php

$container_array=array();

if($page->pagetemplate->container_param!=''){
	$container_array=explode(';',$page->pagetemplate->container_param);
}

if($page->type== 'navitree'){
	echo mymenu::get_nested_subpages($page);
	return;
}

$container_array=$page->pagetemplate->get_container_title_array();
if($container_array){
	foreach($container_array as $container){
	echo '<div class="pagecontainer">';
	echo '<p class="header">'.$container.'</p>';
	echo '<div class="container_content">';
	$count=0;
	$page=ORM::factory('page', $page->id);
	$params=$page->get_contentmodule_list($container,-5+($count*10), CONTDIR);
	echo sigi::addbox($params, 'addmenu');
	
	foreach ($page->orderby('position')->where('container', $container)->where('lang', $this->session->get('lang'))->content as $content){
		
		$content_view=new View('content/single');
		$content_view->content=$content;
		echo $content_view;		
		
		$count++;
		$params=$page->get_contentmodule_list($container,$content->position+5, CONTDIR);
		echo sigi::addbox($params, 'addmenu');
	}

	echo '</div>';
	echo '</div>';
	}
}
?>

</div>
